package org.wanda.pv.model.basic;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;
import org.wanda.pv.framework.base.BaseModel;
import org.wanda.pv.model.business.Mark;

import java.util.List;

/**
 * @author lxy
 * @date 2018/11/15 11:18
 */
@Comment("要点")
@Table("wd_point")
public class Point extends BaseModel {
    @Column
    @Id()
    @Prev(els = {@EL("$me.idGen()")})
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @Comment("要点名称")
    @Column("name")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private String name;


    @Comment("序号")
    @Column
    private String number;

    // 企业题库
    @ManyMany(relation="wd_re_point_point_room",from="point_id",to="point_room_id")
    private List<PointRoom> pointRooms;



    //专业分类
    @ManyMany(relation="wd_re_point_specialty",from="point_id",to="specialty_id")
    private List<Specialty> specialties;

    @ManyMany(relation = "wd_re_mark_point",from = "point_id", to = "mark_id")
    private List<Mark> marks;

    //要点类型、一对一
    @Comment
    @Column("point_class_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long pointClassId;

    //要点类型、一对多
    @One(field="pointClassId")
    private PointClass pointClass;


    //----设计系统
    @Comment
    @Column("system_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long systemId;

    //设计系统关联
    @One(field = "systemId")
    private System system;

    @Column("top_point_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long topPointId;


    @Column
    @Comment("排序字段")
    @Prev({
            @SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM wd_point"),
            @SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM wd_point")
    })
    private Integer location;

    public Integer getLocation() {
        return location;
    }

    public void setLocation(Integer location) {
        this.location = location;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }



    public List<PointRoom> getPointRooms() {
        return pointRooms;
    }

    public void setPointRooms(List<PointRoom> pointRooms) {
        this.pointRooms = pointRooms;
    }



    public List<Specialty> getSpecialties() {
        return specialties;
    }

    public void setSpecialties(List<Specialty> specialties) {
        this.specialties = specialties;
    }

    public Long getPointClassId() {
        return pointClassId;
    }

    public void setPointClassId(Long pointClassId) {
        this.pointClassId = pointClassId;
    }

    public PointClass getPointClass() {
        return pointClass;
    }

    public void setPointClass(PointClass pointClass) {
        this.pointClass = pointClass;
    }



    public Long getSystemId() {
        return systemId;
    }

    public void setSystemId(Long systemId) {
        this.systemId = systemId;
    }


    public System getSystem() {
        return system;
    }

    public void setSystem(System system) {
        this.system = system;
    }

    public List<Mark> getMarks() {
        return marks;
    }

    public void setMarks(List<Mark> marks) {
        this.marks = marks;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public Long getTopPointId() {
        return topPointId;
    }

    public void setTopPointId(Long topPointId) {
        this.topPointId = topPointId;
    }
}
